package com.tjs.lucky.domain.award.service.goods.impl;

import com.tjs.lucky.common.AwardState;
import com.tjs.lucky.common.AwardType;
import com.tjs.lucky.common.GrantState;
import com.tjs.lucky.domain.award.model.vo.DistributionRes;
import com.tjs.lucky.domain.award.model.vo.GoodsReq;
import com.tjs.lucky.domain.award.service.goods.DistributionBase;
import com.tjs.lucky.domain.award.service.goods.IDistributionGoods;
import org.springframework.stereotype.Component;

/**
 * @Author: 田佳澍
 * @Description: 优惠券商品
 * @DateTime: 2023/5/19 10:16
 **/
@Component
public class CouponGoods extends DistributionBase implements IDistributionGoods {
    @Override
    public DistributionRes doDistribution(GoodsReq req) {
        // 模拟调用优惠券发放接口
        logger.info("模拟调用优惠券发放接口 uId：{} awardContent：{}", req.getUId(), req.getAwardContent());

        // 更新用户领奖结果
        super.updateUserAwardState(req.getUId(), req.getOrderId(), req.getAwardId(), GrantState.COMPLETE.getCode());

        return new DistributionRes(req.getUId(), AwardState.SUCCESS.getCode(), AwardState.SUCCESS.getInfo());
    }

    @Override
    public Integer getDistributionGoodsName() {
        return AwardType.CouponGoods.getCode();
    }
}
